package org.study.algorithm.list;

import org.jetbrains.annotations.NotNull;

import java.io.Serializable;
import java.util.*;

public class MyArrayList<E> implements List<E>, RandomAccess, Cloneable, Serializable {

    private transient Object[] DATA;


    private static final int DEFAULT_CAPACITY = 10;
    private static final Object[] EMPTY_DATA = {};
    private int size;

    public MyArrayList() {
        this.DATA = EMPTY_DATA;
    }

    public MyArrayList(int initialCapacity) {
        if (initialCapacity == 0) {
            this.DATA = EMPTY_DATA;
        } else if (initialCapacity > 0) {
            this.DATA = new Object[initialCapacity];
        } else {
            throw new IllegalArgumentException("size error");
        }
    }

    public MyArrayList(Collection<? extends E> c) {
        if (c == null) {
            this.DATA = EMPTY_DATA;
        } else {
            size = c.size();
            if (size == 0) {
                this.DATA = EMPTY_DATA;
            } else {
                Object[] objects = c.toArray();
                if (c instanceof MyArrayList) {
                    this.DATA = objects;
                } else {
                    this.DATA = Arrays.copyOf(objects, objects.length, Object[].class);
                }
            }
        }
    }

    @Override
    public int size() {
        return size;
    }

    @Override
    public boolean isEmpty() {
        return size == 0;
    }

    @Override
    public boolean contains(Object o) {
        return indexOf(o) >= 0;
    }

    @NotNull
    @Override
    public Iterator<E> iterator() {
        return null;
    }

    @NotNull
    @Override
    public Object[] toArray() {
        return new Object[0];
    }

    @NotNull
    @Override
    public <T> T[] toArray(@NotNull T[] a) {
        return null;
    }

    @Override
    public boolean add(E e) {
        return false;
    }

    @Override
    public boolean remove(Object o) {
        return false;
    }

    @Override
    public boolean containsAll(@NotNull Collection<?> c) {
        return false;
    }

    @Override
    public boolean addAll(@NotNull Collection<? extends E> c) {
        return false;
    }

    @Override
    public boolean addAll(int index, @NotNull Collection<? extends E> c) {
        return false;
    }

    @Override
    public boolean removeAll(@NotNull Collection<?> c) {
        return false;
    }

    @Override
    public boolean retainAll(@NotNull Collection<?> c) {
        return false;
    }

    @Override
    public void clear() {

    }

    @Override
    public E get(int index) {
        return null;
    }

    @Override
    public E set(int index, E element) {
        return null;
    }

    @Override
    public void add(int index, E element) {

    }

    @Override
    public E remove(int index) {
        return null;
    }

    @Override
    public int indexOf(Object o) {
        if(size==0){
            return -1;
        }else {

        }
        return 0;
    }

    @Override
    public int lastIndexOf(Object o) {
        return 0;
    }

    @NotNull
    @Override
    public ListIterator<E> listIterator() {
        return null;
    }

    @NotNull
    @Override
    public ListIterator<E> listIterator(int index) {
        return null;
    }

    @NotNull
    @Override
    public List<E> subList(int fromIndex, int toIndex) {
        return null;
    }
}
